﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Personnel_Action_Form.aspx.cs"
    EnableViewState="true" Inherits="Trig_AMJ_HR_Forms.Layouts.Trig_AMJ_HR_Forms.Personnel_Action_Form"
    DynamicMasterPageFile="~masterurl/default.master" %>

<%@ Register TagPrefix="trig" TagName="PersonnelComments" Src="~/_controltemplates/Trig_AMJ_AMG_Forms/TrigAMJFormsComments/TrigAMJFormsCommentsUserControl.ascx" %>
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <link rel="Stylesheet" type="text/css" href="/_layouts/1033/STYLES/Themable/FORMS.CSS" />
    <link rel="Stylesheet" type="text/css" href="/Style Library/Al Majed/CSS/Trig_HR.css" />
    <script language="javascript" type="text/javascript" src="/_layouts/Scripts/validation.js"></script>
    <style type="text/css">
        .ms-validations
        {
            color: Red;
        }
        
        #s4-leftpanel
        {
            display: none;
        }
        .s4-ca
        {
            margin-left: 0px;
        }
        .ms-validations
        {
            color: Red;
        }
        .style2
        {
            width: 373px;
        }
        .style3
        {
            width: 366px;
        }
        body, td, th
        {
            font-size: 8pt;
            font-family: Verdana, Arial, sans-serif;
        }
    </style>
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <asp:Panel ID="pnlFullForm" runat="server" CssClass="pnlAMFform">
        <table cellpadding="0" cellspacing="0" class="tbl-main" width="800px">
            <tr>
                <td colspan="4" class="formtitle">
                    Personnel Action Form
                </td>
            </tr>
            <tr>
                <td colspan="4" class="Note-td">
                    <asp:Label ID="lblnote1" runat="server" Text="Some notes will be come here!!!" CssClass="Notes-msg"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>
                    Reference No :
                </td>
                <td>
                    <asp:Label ID="lblActReqNo" runat="server" Text="Reference number will be generated upon save"
                        Font-Bold="True" Font-Size="XX-Small" CssClass="ms-long ms-spellcheck-true" ForeColor="Red"></asp:Label>
                </td>
                <td>
                    Date of filling :
                </td>
                <td>
                    <SharePoint:DateTimeControl ID="dtReqDate" runat="server" DateOnly="true" IsRequiredField="true"
                        Enabled="false" LocaleId="2057" />
                </td>
            </tr>
            <tr>
                <td class="tdHeadingTextLeftAlign" colspan="4">
                    Type of Action (Please Specify)
                </td>
            </tr>
            <tr>
                <td colspan="1">
                    User : <span title="This is a required field." class="ms-validations"><strong>*</strong></span>
                </td>
                <td colspan="1">
                    <SharePoint:PeopleEditor runat="server" ID="pplActUser" MultiSelect="false" Width="250px" />
                </td>
                <td colspan="1">
                    Name : <span title="This is a required field." class="ms-validations"><strong>*</strong></span>
                </td>
                <td colspan="1">
                    <asp:TextBox runat="server" ID="txtName" Width="250px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="1">
                    Type of Action (Please Specify) <span title="This is a required field." class="ms-validations">
                        <strong>*</strong></span>
                </td>
                <td colspan="1">
                    <asp:DropDownList runat="server" ID="ddlActionType" Width="250px" OnSelectedIndexChanged="ddlActionType_SelectedIndexChanged"
                        AutoPostBack="true">
                    </asp:DropDownList>
                </td>
                <td colspan="2">
                    <asp:TextBox runat="server" ID="txtOthers" Width="400px" Visible="false"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="tdHeadingTextLeftAlign" colspan="4">
                    Employee Information
                </td>
            </tr>
            <tr>
                <td>
                    Natinality : <span title="This is a required field." class="ms-validations"><strong>
                        *</strong></span>
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="ddlNationality" Width="250px">
                    </asp:DropDownList>
                </td>
                <td>
                    Employee No : <span title="This is a required field." class="ms-validations"><strong>
                        *</strong></span>
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txtEmployeeNo" Width="250px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Date of Birth : <span title="This is a required field." class="ms-validations"><strong>
                        *</strong></span>
                </td>
                <td>
                    <SharePoint:DateTimeControl ID="dtDOB" runat="server" DateOnly="true" LocaleId="2057" />
                </td>
                <td>
                    Marital Status :
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="ddlMaritalStatus" EnableViewState="true">
                        <asp:ListItem Text="Single" Value="0" Selected="True"></asp:ListItem>
                        <asp:ListItem Text="Married" Value="1"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    Father's Name : </strong><span class="ms-validations" title="This is a required field."><strong>
                        *</strong></span>
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txtFathersName" Width="250px"></asp:TextBox>
                </td>
                <td>
                    No. of Dependants :
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txtNoDependant" Width="250px" onkeypress="return isNumberKey(this)"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Address :
                </td>
                <td rowspan="3">
                    <asp:TextBox runat="server" ID="txtAddress" TextMode="MultiLine" Width="250px" Height="75px"></asp:TextBox>
                </td>
                <td>
                    Telephone No :
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txtTelNo" Width="250px" onkeypress="return isNumberKey(this)"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    Passport No : <span title="This is a required field." class="ms-validations"><strong>
                        *</strong></span>
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txtPassportNo" Width="250px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    Validity of Passport : <span title="This is a required field." class="ms-validations">
                        <strong>*</strong></span>
                </td>
                <td>
                    <SharePoint:DateTimeControl ID="dtPassValidity" runat="server" DateOnly="true" LocaleId="2057" />
                </td>
            </tr>
            <tr>
                <td>
                    Date of Employment : <span title="This is a required field." class="ms-validations">
                        <strong>*</strong></span>
                </td>
                <td>
                    <SharePoint:DateTimeControl ID="dtDOE" runat="server" DateOnly="true" LocaleId="2057" />
                </td>
                <td>
                    Qatar ID No : <span title="This is a required field." class="ms-validations"><strong>
                        *</strong></span>
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txtQadarID" Width="250px"></asp:TextBox>
                </td>
            </tr>
            <tr runat="server" id="tdDup">
                <td>
                    Validity of Resident Permit : <span title="This is a required field." class="ms-validations">
                        <strong>*</strong></span>
                </td>
                <td>
                    <SharePoint:DateTimeControl ID="dtValofResPermit" runat="server" DateOnly="true"
                        LocaleId="2057" />
                </td>
            </tr>
            <%-- <tr>
                <td class="tdHeadingTextLeftAlign" colspan="4">
                    Type of Action (Please Specify)
                </td>
            </tr>
            <tr>
                <td colspan="1">
                    Type of Action (Please Specify) <span title="This is a required field." class="ms-validations">
                        <strong>*</strong></span>
                </td>
                <td colspan="1">
                    <asp:DropDownList runat="server" ID="ddlActionType" Width="250px" OnSelectedIndexChanged="ddlActionType_SelectedIndexChanged"
                        AutoPostBack="true">
                    </asp:DropDownList>
                </td>
                <td colspan="2">
                    <asp:TextBox runat="server" ID="txtOthers" Width="400px" Visible="false"></asp:TextBox>
                </td>
            </tr>--%>
            <tr>
                <td class="tdHeadingTextLeftAlign" colspan="4">
                    Status / Classification
                </td>
            </tr>
            <tr>
                <td>
                    Designation (Previous) <span title="This is a required field." class="ms-validations">
                        <strong>*</strong></span>
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="ddlDesigPrev" Width="250px">
                    </asp:DropDownList>
                </td>
                <td>
                    Designation (Present) <span title="This is a required field." class="ms-validations">
                        <strong>*</strong></span>
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="ddlDesigPres" Width="250px">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <asp:Panel runat="server" ID="pnlDiv">
                    <td>
                        Division (Previous) <span title="This is a required field." class="ms-validations"><strong>
                            *</strong></span>
                    </td>
                    <td>
                        <asp:DropDownList runat="server" ID="ddlDivPrev" Width="250px">
                        </asp:DropDownList>
                    </td>
                </asp:Panel>
                <td>
                    Division (Present) <span title="This is a required field." class="ms-validations"><strong>
                        *</strong></span>
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="ddlDivPres" Width="250px">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr runat="server" id="tr1">
                <td colspan="4">
                    <asp:UpdatePanel ID="UpdatePanel6" runat="server">
                        <ContentTemplate>
                            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CssClass="Grid-default"
                                AlternatingRowStyle-CssClass="alt-tr" ShowFooter="True" OnRowDataBound="GridView1_RowDataBound">
                                <Columns>
                                    <asp:TemplateField HeaderText="S. No.">
                                        <ItemTemplate>
                                            <%#Container.DataItemIndex+1 %>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Status / Classification">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtSpecification" runat="server" Width="250px" Text='<%# Eval("Class") %>'></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Previous" ItemStyle-HorizontalAlign="Center">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtPrevious" runat="server" Width="250px" Text='<%# Eval("Previous") %>'></asp:TextBox>
                                        </ItemTemplate>
                                        <FooterTemplate>
                                            <asp:Label ID="lblPreviousTtl" runat="server" Visible="true"></asp:Label>
                                        </FooterTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Present" ItemStyle-HorizontalAlign="Center">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtPresent" runat="server" Width="250px" Text='<%# Eval("Present") %>'></asp:TextBox>
                                        </ItemTemplate>
                                        <FooterTemplate>
                                            <asp:Label ID="lblPresentTtl" runat="server" Visible="true"></asp:Label>
                                        </FooterTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
            <tr runat="server" id="trNewGv">
                <td colspan="4">
                    <asp:UpdatePanel ID="upPnl" runat="server">
                        <ContentTemplate>
                            <asp:GridView ID="gvSalaryInfo" runat="server" AutoGenerateColumns="False" CssClass="Grid-default"
                                AlternatingRowStyle-CssClass="alt-tr" ShowFooter="True" OnRowDataBound="gvSalaryInfo_RowDataBound"
                                OnSelectedIndexChanged="gvSalaryInfo_OnSelectedIndexChanged" OnRowCommand="gvSalaryInfo_RowCommand">
                                <Columns>
                                    <asp:TemplateField HeaderText="S. No.">
                                        <ItemTemplate>
                                            <%#Container.DataItemIndex+1 %>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Status / Classification">
                                        <ItemTemplate>
                                            <asp:HiddenField runat="server" ID="hdnClass" />
                                            <asp:DropDownList runat="server" ID="ddlSpecification" Width="250px" AutoPostBack="true"
                                                OnSelectedIndexChanged="ddlSpecification_Selectedindexchanged">
                                            </asp:DropDownList>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Previous" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Right"
                                        FooterStyle-VerticalAlign="Middle">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtPrevious" runat="server" Width="250px" onkeypress="return isNumberKey(this)"></asp:TextBox>
                                        </ItemTemplate>
                                        <FooterTemplate>
                                            <asp:Label ID="lblPreviousTtl" runat="server" Visible="true"></asp:Label>
                                        </FooterTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Present" ItemStyle-HorizontalAlign="Center">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtPresent" runat="server" Width="250px" onkeypress="return isNumberKey(this)"></asp:TextBox>
                                        </ItemTemplate>
                                        <FooterTemplate>
                                            <asp:Label ID="lblPresentTtl" runat="server" Visible="true"></asp:Label>
                                        </FooterTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Delete" ItemStyle-HorizontalAlign="Center">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="imgbtnDelete" runat="server" ImageUrl="~/_layouts/1033/IMAGES/AlmajedCustoms/delete.png"
                                                AlternateText="Delete" ToolTip="Delete Row" Height="17" CommandName="ReDelete"
                                                CommandArgument='<%#Container.DataItemIndex%>' OnClientClick="javascript:return confirm('Are you sure do you want to Delete?')" />
                                        </ItemTemplate>
                                        <FooterTemplate>
                                            <asp:ImageButton ID="Bbtnadd" runat="server" ImageUrl="~/_layouts/1033/IMAGES/AlmajedCustoms/AddNew.png"
                                                OnClick="Bbtnadd_Click" OnClientClick="javascript:return validateGridview();" />
                                        </FooterTemplate>
                                        <FooterStyle HorizontalAlign="Center" />
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
            <tr>
                <td colspan="4" class="tdHeadingTextLeftAlign">
                    Comments / Workflow Area
                </td>
            </tr>
            <tr>
                <td colspan="4" style="padding: 10px;">
                    <trig:PersonnelComments ID="PersonnelComments" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <table width="100%" cellpadding="0" cellspacing="0" class="Section-Approver">
                        <asp:Panel ID="pnlCommentArea" runat="server" class="Section-Approver">
                            <tr>
                                <td colspan="4" class="AppHeading">
                                    <strong>Comments</strong><span class="ms-validations" title="This is a required field."><strong>
                                        *</strong></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="tdCell">
                                    <asp:Image ID="ImgUser" runat="server" Height="50px" Width="50px" />
                                    <br />
                                    <asp:Label ID="LblCommentsUserName" runat="server" Font-Bold="True" Font-Size="XX-Small"
                                        ForeColor="#003399" Text=""></asp:Label>
                                </td>
                                <td colspan="3" class="tdCell">
                                    <asp:TextBox ID="TxtComments" runat="server" TextMode="MultiLine" Width="600px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr id="upAtt" runat="server">
                                <td class="tdCell">
                                    Upload Attachment
                                </td>
                                <td colspan="3" class="tdCell">
                                    <asp:FileUpload ID="upfile" runat="server" CssClass="ms-fileinput" Width="250px" />
                                </td>
                            </tr>
                        </asp:Panel>
                        <asp:Panel ID="pnlForward" runat="server" Visible="false">
                            <tr>
                                <td colspan="4" style="text-align: left; background-color: #121e66; color: #ffffff;
                                    font-weight: bold; padding: 10px;">
                                    <table cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td>
                                                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                                    <ContentTemplate>
                                                        <asp:RadioButton ID="rtbSendBack" runat="server" Text="Send Back" GroupName="Users"
                                                            AutoPostBack="true" onclick="javascript:fnSendBackUsers(this)" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:AsyncPostBackTrigger ControlID="rtbSendBack" EventName="CheckedChanged" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                            <td>
                                                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                                    <ContentTemplate>
                                                        <asp:RadioButton ID="rtbForwardOthers" runat="server" Text="Forward to other user"
                                                            AutoPostBack="true" GroupName="Users" onclick="javascript:fnForwardUsers(this)" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:AsyncPostBackTrigger ControlID="rtbForwardOthers" EventName="CheckedChanged" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                            <td>
                                                <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                                                    <ContentTemplate>
                                                        <asp:RadioButton ID="rtbForward" runat="server" Text="Forward" GroupName="Users"
                                                            AutoPostBack="true" onclick="javascript:fnForword(this)" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:AsyncPostBackTrigger ControlID="rtbForward" EventName="CheckedChanged" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="3">
                                                <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                                                    <ContentTemplate>
                                                        <asp:Label ID="lblWFStaticUser" runat="server" Text="" Font-Bold="True" Font-Size="XX-Small"
                                                            ForeColor="Yellow"></asp:Label>
                                                        <asp:Label ID="lblSendBacktoUser" runat="server" Text="" Font-Bold="True" Font-Size="XX-Small"
                                                            ForeColor="Yellow" Visible="false"></asp:Label>
                                                        <asp:Label ID="lblsendBackUserValue" runat="server" Text="" Font-Bold="True" Font-Size="XX-Small"
                                                            ForeColor="Yellow"></asp:Label>
                                                    </ContentTemplate>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr style="padding: 10px; display: none" id="trotherUsers">
                                <td style="padding: 10px; font-weight: bold; color: #121e66;" width="130px">
                                    User Name :
                                </td>
                                <td style="padding: 10px;" colspan="3">
                                    <asp:Label ID="lblCNTSectionMsg" runat="server" Text=""></asp:Label>
                                    <SharePoint:PeopleEditor ID="pplcnt" runat="server" MultiSelect="false" AllowEmpty="false"
                                        Width="250px" ForeColor="Red" AutoPostBack="false" />
                                </td>
                            </tr>
                        </asp:Panel>
                        <asp:Panel runat="server" ID="btnCntrls">
                            <tr>
                                <td colspan="4">
                                    <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                                        <ContentTemplate>
                                            <asp:Label ID="lblError" runat="server" CssClass="error-msg" Text=""></asp:Label>
                                        </ContentTemplate>
                                    </asp:UpdatePanel>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="4" class="tblButtons" style="padding-top: 5px;">
                                    <asp:HiddenField runat="server" ID="ckSubmit" Value="false" />
                                    <asp:Button ID="btnSubmit" runat="server" CssClass="btn-Submit" Text="Submit" OnClientClick="javascript:return fnValidation();"
                                        OnClick="btnSubmit_Click" />
                                    <asp:Button ID="btnApprove" runat="server" CssClass="btn-Approver" Text="Approve"
                                        OnClick="btnApprove_Click" OnClientClick="javascript:return fnValidationApprove();"
                                        Visible="false" />
                                    <asp:Button ID="btnReject" runat="server" CssClass="btn-Reject" Text="Reject" Visible="false"
                                        OnClick="btnReject_Click" OnClientClick="javascript:return fnValidationApprove();" />
                                    <input id="btnCancel" class="btn-Cancel" type="button" value="Close" accesskey="C"
                                        onclick="window.close()" runat="server" />
                                </td>
                            </tr>
                        </asp:Panel>
                    </table>
                </td>
            </tr>
            <asp:Panel ID="pnlView" runat="server" Visible="false">
                <tr>
                    <td colspan="4" style="text-align: center;">
                        <input id="btnViewClose" class="btn-Cancel" type="button" onclick="window.parent.history.back()"
                            value="Close" accesskey="C" />
                    </td>
                </tr>
            </asp:Panel>
        </table>
    </asp:Panel>
    <asp:Panel ID="pnlAccessDenied" runat="server" Visible="false" CssClass="pnlAMFform">
        <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td style="text-align: center;">
                    <asp:Label ID="lblAccessDeniedMsg" runat="server" Text="" Font-Size="Medium" ForeColor="Red"
                        Font-Bold="True" Visible="false"></asp:Label>
                    <asp:Label ID="lblUserNotvailable" runat="server" Text="" Font-Size="Medium" ForeColor="Red"
                        Font-Bold="True" Visible="false"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: center; padding-top: 10px;">
                    <asp:Image ID="Image1" runat="server" ImageUrl="~/_layouts/1033/IMAGES/IRForm/AccessDeniedImage.png" />
                </td>
            </tr>
            <tr>
                <td style="text-align: center; padding-top: 10px">
                    <input id="butonclose" class="ms-ButtonHeightWidth" type="button" onclick="SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, 'Cancel clicked'); return false;"
                        value="Close" accesskey="C" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="pnlAlert" runat="server">
    </asp:Panel>
    <script language="javascript" type="text/javascript">

        document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
        document.getElementById('<%= lblError.ClientID  %>').style.display = "none";

        function fnValidationApprove() {

            debugger;
            document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
            Trim(document.getElementById('<%= TxtComments.ClientID  %>'));

            var rval = true;
            var ErrorMsg = "";
            var objFocus;

            if (document.getElementById('<%= TxtComments.ClientID  %>').value == "") {
                ErrorMsg = "Fields marked with (*) cannot be left blank";
                objFocus = document.getElementById('<%= TxtComments.ClientID  %>');
                rval = false;
            }

            if (rval == false) {
                document.getElementById('<%= lblError.ClientID  %>').style.display = "block";
                document.getElementById('<%= lblError.ClientID  %>').innerHTML = ErrorMsg;
                objFocus.focus();
            }

            else {
                document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
                document.getElementById('<%= lblError.ClientID  %>').style.display = "none";
            }
            return rval;
        }
    
    </script>
    <%--<script language="javascript" type="text/javascript">


        function SelectedItem(seltext) {

            var cellText = seltext;
            var grid = document.getElementById("<%= gvSalaryInfo.ClientID %>"); //GridView1(ID of the gridview)
            if (grid.rows.length != 0) {
                //loop starts from 1. rows[0] points to the header.

                for (i = 1; i < grid.rows.length; i++) {

                    var rowone = grid.parentNode.childNodes.item(0).childNodes.item(0).childNodes.item(i).childNodes.item(1);

                    if (!isEmpty(rowone)) {
                        String.prototype.toElement = function () {
                            var t = document.createElement("div");
                            t.innerHTML = this;
                            return t.getElementsByTagName("*")[0];
                        }

                        var sel = rowone.innerHTML.toElement();

                        if (!isEmpty(sel)) {
                            alert(sel.options[sel.selectedIndex].value); //alert selected value of drop down list
                            if (sel.options[sel.selectedIndex].text == cellText) //alert selected text of drop down list
                                alert("Duplication Records");
                            else
                                alert("OK");
                        }
                    }

                }
            }
        }

        function grd(grid, indx) {
            var grd;
            var isVal = false;
            try {
                grd = grid.parentNode.childNodes.item(0).childNodes.item(0).childNodes.item(indx).childNodes.item(1);
                isVal = true;
            } catch (e) {
                isVal = false;

            }
            return isVal;
        }


        function EnableTextBoxValidation(objDDL) {
            var ddlDOM = document.getElementById(objDDL);
            //if (ddlDOM.selectedIndex > 0) {
            var selvalue = ddlDOM.value; //Grab the selected value
            var seltext = ddlDOM.options[ddlDOM.selectedIndex].text; //
            SelectedItem(seltext);
            //}
        }


        function storeSelectedValue(selobj, hfId) {
            // Call this function on the "onchange" of all DropDowns which are populated using JavaScript
            var selvalue = selobj.value; //Grab the selected value
            alert(selvalue);
            var seltext = selobj.options[selobj.selectedIndex].text; // Or grab the selected text
            alert(seltext);
            document.getElementById(hfId).value = selvalue; // Or seltext
            // Retrive the value on the server from this Hidden Field
        }

    </script>--%>
    <script language="javascript" type="text/javascript">
        document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
        document.getElementById('<%= lblError.ClientID  %>').style.display = "none";
        function isNumberKey(evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;
        }

        function isValid() {
            var iChars = "@~`!#$%^&*+=-[]\\\';,/{}|\":<>?().";
            var str = document.getElementById('<%= txtEmployeeNo.ClientID %>').value;
            for (var i = 0; i < str.length; i++) {
                if (iChars.indexOf(str.charAt(i)) != -1) {
                    alert("Special characters not allowed");
                    document.getElementById('<%= txtEmployeeNo.ClientID %>').focus();
                    return false;
                }
            }
            return true;
        }

        function isValids() {
            var iChars = "@~`!#$%^&*+=-[]\\\';,/{}|\":<>?()";
            var str = document.getElementById('<%= txtFathersName.ClientID %>').value;
            for (var i = 0; i < str.length; i++) {
                if (iChars.indexOf(str.charAt(i)) != -1) {
                    alert("Special characters not allowed");
                    document.getElementById('<%= txtFathersName.ClientID %>').focus();
                    return false;
                }
            }
            return true;
        }

        function isValidity() {
            var iChars = "@~`!#$%^&*+=-[]\\\';,/{}|\":<>?()";
            var str = document.getElementById('<%= txtName.ClientID %>').value;
            for (var i = 0; i < str.length; i++) {
                if (iChars.indexOf(str.charAt(i)) != -1) {
                    alert("Special characters not allowed");
                    document.getElementById('<%= txtName.ClientID %>').focus();
                    return false;
                }
            }
            return true;
        }

    </script>
    <script language="javascript" type="text/javascript">

        document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
        document.getElementById('<%= lblError.ClientID  %>').style.display = "none";

        function validateGridview() {

            debugger;
            var ItemVal;
            var grid = document.getElementById('<%=gvSalaryInfo.ClientID%>');
            var grids = document.getElementById('<%=gvSalaryInfo.ClientID%>');
            if (grid != null) {
                for (j = 1; j < grids.rows.length; j++) {
                    {
                        var text = grid.rows[j].getElementsByTagName("input");

                        for (var i = 0; i < text.length; i++) {
                            if (text[i].type == 'text') {
                                if (text[i].value == "") {
                                    alert('Plese fill the details');
                                    return false;
                                }
                            }
                        }

                        var dropdowns = grid.rows[j].getElementsByTagName('select'); //Get all dropdown lists contained in GridView1.
                        for (var i = 0; i < dropdowns.length; i++) {
                            if (dropdowns.item(i).value == 'Select') //If dropdown has no selected value
                            {
                                alert('Please select the details');
                                return false;

                            }
                        }
                        //                        text = grid.rows[j].getElementsByTagName("textarea");
                        //                        for (i = 0; i < text.length; i++) {
                        //                            if (text[i].id.search("txtDescription") != "-1") {
                        //                                ItemVal = text[i].value;
                        //                            }
                        //                        }
                        //                        if (ItemVal == "") {
                        //                            alert('Please fill the details');
                        //                            return false;
                        //                        }
                    }
                }
            }
        }
		 
    </script>
    <script language="javascript" type="text/javascript">

        document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
        document.getElementById('<%= lblError.ClientID  %>').style.display = "none";

        function getParameterByName(name) {
            name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regexS = "[\\?&]" + name + "=([^&#]*)";
            var regex = new RegExp(regexS);
            var results = regex.exec(window.location.search);
            if (results == null)
                return "";
            else
                return decodeURIComponent(results[1].replace(/\+/g, " "));
        }

        function Trim(TrimString) {
            var tempObj;
            if (TrimString) { tempObj = TrimString; TrimString = tempObj.value; }
            if (TrimString == "undefined" || TrimString == null) return null;
            if (TrimString.length == 0) TrimString = "";
            else {
                var Lcont = 0, TempStrArray = TrimString.split(" "), Rcont = TempStrArray.length - 1;
                while (TempStrArray[Lcont] == "") Lcont++; while (TempStrArray[Rcont] == "") Rcont--;
                if (Rcont < Lcont) TrimString = ""; else
                    for (TrimString = TempStrArray[Lcont], Lcont++; Lcont <= Rcont; Lcont++) TrimString += " " + TempStrArray[Lcont];
                var re = /\'|/g;
                TrimString = TrimString.replace(re, "");
            }
            if (tempObj && TrimString != "undefined" && TrimString != null)
            { tempObj.value = TrimString; return tempObj }
            else return TrimString;
        }


        function isSPID() {
            var employeeID = Trim(document.getElementById('<%= txtEmployeeNo.ClientID  %>'));
            var iChars = "@~`!#$%^&*+=-[]\\\';,/{}|\":<>?().";
            var str = employeeID.value;
            for (var i = 0; i < str.length; i++) {
                if (iChars.indexOf(str.charAt(i)) != -1) {
                    return true;
                }
            }
            return false;
        }

        function isSPN() {
            var name = Trim(document.getElementById('<%= txtName.ClientID  %>'));
            var iChars = "@~`!#$%^&*+=-[]\\\';,/{}|\":<>?().";
            var str = name.value;
            for (var i = 0; i < str.length; i++) {
                if (iChars.indexOf(str.charAt(i)) != -1) {
                    return true;
                }
            }
            return false;
        }

        function isSPName() {
            var fName = Trim(document.getElementById('<%= txtFathersName.ClientID  %>'));
            var iChars = "@~`!#$%^&*+=-[]\\\';,/{}|\":<>?().";
            var str = fName.value;
            for (var i = 0; i < str.length; i++) {
                if (iChars.indexOf(str.charAt(i)) != -1) {
                    return true;
                }
            }
            return false;
        }

        function fnValidation() {
            var isDateEmpty = false;
            debugger;
            var querystringval = getParameterByName('Mode');
            var rval = true;
            var ErrorMsg = "";
            var objFocus;


            if (querystringval == "New") {

                var dtDt = Trim(document.getElementById('<%= dtReqDate.Controls[0].ClientID  %>'));
                var user = Trim(document.getElementById('<%= pplActUser.ClientID  %>'));
                var name = Trim(document.getElementById('<%= txtName.ClientID  %>'));
                var fname = Trim(document.getElementById('<%= txtFathersName.ClientID  %>'));
                var nationality = Trim(document.getElementById('<%= ddlNationality.ClientID  %>'));
                var employeeID = Trim(document.getElementById('<%= txtEmployeeNo.ClientID  %>'));
                var dob = document.getElementById('<%= dtDOB.Controls[0].ClientID %>');
                var passNo = Trim(document.getElementById('<%= txtPassportNo.ClientID  %>'));
                var passExpDt = Trim(document.getElementById('<%= dtPassValidity.Controls[0].ClientID %>'));
                var doe = Trim(document.getElementById('<%= dtDOE.Controls[0].ClientID  %>'));
                var qatarID = Trim(document.getElementById('<%= txtQadarID.ClientID  %>'));
                var resPermit = Trim(document.getElementById('<%= dtValofResPermit.Controls[0].ClientID %>'));
                var actionType = Trim(document.getElementById('<%= ddlActionType.ClientID  %>'));
                var ActionOthers = Trim(document.getElementById('<%= txtOthers.ClientID  %>'));

                var desPrev = Trim(document.getElementById('<%= ddlDesigPrev.ClientID  %>'));
                var desPres = Trim(document.getElementById('<%= ddlDesigPres.ClientID  %>'));

                var divPrev = Trim(document.getElementById('<%= ddlDivPrev.ClientID  %>'));
                var divPres = Trim(document.getElementById('<%= ddlDivPres.ClientID  %>'));

                //Grab the selected value

                var ActType = actionType.options[actionType.selectedIndex].text; //
                var Nationality = nationality.options[nationality.selectedIndex].text;

                var PrevDes = desPrev.options[desPrev.selectedIndex].text; //
                var PresDes = desPres.options[desPres.selectedIndex].text; //
                if (divPrev != null)
                    var PrevDiv = divPrev.options[divPrev.selectedIndex].text; //
                var PresDiv = divPres.options[divPres.selectedIndex].text; //

            }

            var comments = Trim(document.getElementById('<%= TxtComments.ClientID  %>'));

            if (querystringval == "New") {


                var grid = document.getElementById('<%=gvSalaryInfo.ClientID%>');
                var grids = document.getElementById('<%=gvSalaryInfo.ClientID%>');

                if (isEmpty(user)) {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = user;
                    rval = false;
                }
                else if (isEmpty(name)) {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = name;
                    rval = false;
                }
                else if (isSPN()) {
                    ErrorMsg = "Special characters not allowed";
                    objFocus = name;
                    rval = false;
                }
                else if (ActType == "Select") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = actionType;
                    rval = false;
                }

                else if (ActType == "Others" && isEmpty(ActionOthers)) {

                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = ActionOthers;
                    rval = false;
                }
                else if (Nationality == "Select") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = nationality;
                    rval = false;
                }
                else if (isEmpty(employeeID)) {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = employeeID;
                    rval = false;
                }

                else if(isSPID()) {
                    ErrorMsg = "Special characters not allowed";
                    objFocus = employeeID;
                    rval = false;
                }

                else if (isEmpty(dob)) {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = dob;
                    rval = false;
                }
                else if (!isEmpty(dob)) {
                    if (!IsValidDateFormat(dob.value)) {
                        ErrorMsg = "Date format should be dd/mm/yyyy !";
                        objFocus = dob;
                        rval = false;
                    }

                    else {
                        if (!PreSaveAction(dob, dtDt)) {
                            ErrorMsg = "The DOB cannot happen longer than the Today";
                            objFocus = dob;
                            rval = false;
                        }

                        else if (isEmpty(fname)) {
                            ErrorMsg = "Fields marked with (*) cannot be left blank";
                            objFocus = fname;
                            rval = false;
                        }
                        else if (isSPName()) {
                            ErrorMsg = "Special characters not allowed";
                            objFocus = fname;
                            rval = false;
                        }
                        else if (isEmpty(passNo)) {
                            ErrorMsg = "Fields marked with (*) cannot be left blank";
                            objFocus = passNo;
                            rval = false;
                        }
                        else if (isEmpty(passExpDt)) {
                            ErrorMsg = "Fields marked with (*) cannot be left blank";
                            objFocus = passExpDt;
                            rval = false;
                        }

                        else if (!isEmpty(passExpDt)) {
                            if (!IsValidDateFormat(passExpDt.value)) {
                                ErrorMsg = "Date format should be dd/mm/yyyy !";
                                objFocus = passExpDt;
                                rval = false;
                            }

                            else {
                                if (!PreSaveAction(dob, passExpDt)) {
                                    ErrorMsg = "The Passport validatity should be greater than the DOB";
                                    objFocus = passExpDt;
                                    rval = false;
                                }
                                else if (!PreSaveAction(dtDt, passExpDt)) {
                                    ErrorMsg = "The Passport validatity should be greater than the Today";
                                    objFocus = passExpDt;
                                    rval = false;
                                }
                                else if (isEmpty(doe)) {
                                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                                    objFocus = doe;
                                    rval = false;
                                }
                                else if (!isEmpty(doe)) {
                                    if (!IsValidDateFormat(doe.value)) {
                                        ErrorMsg = "Date format should be dd/mm/yyyy !";
                                        objFocus = resPermit;
                                        rval = false;
                                    }

                                    else {
                                        if (!PreSaveAction(dob, doe)) {
                                            ErrorMsg = "The Date of Employeement should be greater than the DOB";
                                            objFocus = doe;
                                            rval = false;
                                        }

                                        else if (isEmpty(qatarID)) {
                                            ErrorMsg = "Fields marked with (*) cannot be left blank";
                                            objFocus = qatarID;
                                            rval = false;
                                        }
                                        else if (isEmpty(resPermit)) {
                                            ErrorMsg = "Fields marked with (*) cannot be left blank";
                                            objFocus = resPermit;
                                            rval = false;
                                        }

                                        else if (!isEmpty(resPermit)) {
                                            if (!IsValidDateFormat(resPermit.value)) {
                                                ErrorMsg = "Date format should be dd/mm/yyyy !";
                                                objFocus = resPermit;
                                                rval = false;
                                            }

                                            else {
                                                if (!PreSaveAction(dob, resPermit)) {
                                                    ErrorMsg = "The Validity of resident permit should be greater than the DOB";
                                                    objFocus = resPermit;
                                                    rval = false;
                                                }
                                                else if (!PreSaveAction(dtDt, resPermit)) {
                                                    ErrorMsg = "The Validity of resident permit should be greater than the Today";
                                                    objFocus = resPermit;
                                                    rval = false;
                                                }
                                                else if (!PreSaveAction(resPermit, passExpDt)) {
                                                    ErrorMsg = "The Validity of resident permit should be lesser than paasport expiry date";
                                                    objFocus = resPermit;
                                                    rval = false;
                                                }
                                                else if (PrevDes == "Select") {
                                                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                                                    objFocus = desPrev;
                                                    rval = false;
                                                }
                                                else if (PresDes == "Select") {
                                                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                                                    objFocus = desPres;
                                                    rval = false;
                                                }
                                                else if (ActType != "Appointment" && PrevDiv == "Select") {
                                                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                                                    objFocus = divPrev;
                                                    rval = false;
                                                }
                                                else if (PresDiv == "Select") {
                                                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                                                    objFocus = divPres;
                                                    rval = false;
                                                }

                                                else if (grid != null) {
                                                    for (j = 1; j < grids.rows.length; j++) {
                                                        var itemVal;
                                                        var text = grid.rows[j].getElementsByTagName("input");
                                                        for (var i = 0; i < text.length; i++) {
                                                            if (text[i].type == 'text') {
                                                                if (text[i].value == "") {
                                                                    ErrorMsg = "Please fill the personnel action details. One row is mandatory. Or personnel action cannot be left blank";
                                                                    objFocus = grid;
                                                                    rval = false;
                                                                }
                                                            }
                                                        }
                                                        var dropdowns = grid.rows[j].getElementsByTagName('select'); //Get all dropdown lists contained in GridView1.
                                                        for (var i = 0; i < dropdowns.length; i++) {
                                                            if (dropdowns.item(i).value == 'Select') //If dropdown has no selected value
                                                            {
                                                                ErrorMsg = "Please fill the personnel action details. One row is mandatory. Or personnel action cannot be left blank";
                                                                objFocus = grid;
                                                                rval = false;
                                                            }
                                                        }
                                                        text = grid.rows[j].getElementsByTagName("textarea");
                                                        for (i = 0; i < text.length; i++) {
                                                            if (text[i].id.search("txtPresent") != "-1") {
                                                                itemVal = text[i].value;
                                                            }
                                                            else if (text[i].id.search("txtPrevious") != "-1") {
                                                                itemVal = text[i].value;
                                                            }
                                                        }
                                                        if (itemVal == "") {
                                                            ErrorMsg = "Please fill the personnel action details. One row is mandatory. Or personnel action details cannot be left blank";
                                                            objFocus = grid;
                                                            rval = false;
                                                        }
                                                        else if (isEmpty(comments)) {
                                                            ErrorMsg = "Fields marked with (*) cannot be left blank";
                                                            objFocus = comments;
                                                            rval = false;
                                                        }

                                                    }
                                                }

                                            }
                                        }

                                    }
                                }
                            }
                        }
                    }
                }
            }
            else {
                if (isEmpty(comments)) {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = comments;
                    rval = false;
                }
            }

            if (rval == false) {
                document.getElementById('<%= lblError.ClientID  %>').style.display = "block";
                document.getElementById('<%= lblError.ClientID  %>').innerHTML = ErrorMsg;
                objFocus.focus();
            }
            else {
                document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
                document.getElementById('<%= lblError.ClientID  %>').style.display = "none";
            }
            return rval;


        }
	
    </script>
    <script language="javascript" type="text/javascript">
        document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
        document.getElementById('<%= lblError.ClientID  %>').style.display = "none";
        function updateValue(field, rowIdx, col) {
            var ColCount = 7;
            var rowTtl2 = 0; var rowTtl3 = 0;
            var cell2 = 0; var cell3 = 0;

            var sum = 0; var sum1 = 0;
            var j = 0;
            if (field.value.length > 0) {
                field.value = field.value.replace(/[^\d]+/g, '');
            }
            rowIdx = parseInt(rowIdx) + 1;

            var objGridView = document.getElementById('<%=gvSalaryInfo.ClientID%>');

            cell2 = objGridView.rows[rowIdx].cells[2].children[0].value;
            cell3 = objGridView.rows[rowIdx].cells[3].children[0].value;

            rowTtl2 = rowTtl2 + parseInt(cell2);
            rowTtl3 = rowTtl3 + parseInt(cell3);

            var gridLength = objGridView.rows.length;
            for (var i = 1; i < objGridView.rows.length - 1; i++) //setting the incrementor=0, but if you have a header set it to 1
            {
                if (!isEmpty(objGridView.rows[i].cells[2].innerText)) {
                    sum = parseFloat(sum) + parseFloat(objGridView.rows[i].cells[2].children[0].value);
                }

                if (!isEmpty(objGridView.rows[i].cells[3].innerText)) {
                    sum1 = parseFloat(sum1) + parseFloat(objGridView.rows[i].cells[3].children[0].value);
                }
            }

            if (!isEmpty(sum)) {
                objGridView.rows[gridLength - 1].cells[2].innerHTML = sum;
            }
            if (!isEmpty(sum1)) {
                objGridView.rows[gridLength - 1].cells[3].innerHTML = sum1;
            }

        }
	
    </script>
</asp:Content>
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    Personnel Action Form
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"
    runat="server">
    Personnel Action Form
</asp:Content>
